﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>登录</title>
    @Scripts.Render("~/bundles/easyui_scripts")
    @Styles.Render("~/bundles/easyui_style")
</head>
<body style="background:url(../images/背景.jpg);background-size:cover;

        background-attachment:fixed;">
    <div class="easyui-panel" style="border:none;width:400px;padding:50px 60px;position:fixed; top:40%;left:50%;transform: translate(-50%,-50%);opacity: 0.85;border-radius:20px;">
        <div>
            <h2 style="text-align:center;color:#707070;font-weight:600;">仓库后台登录</h2>
        </div>
        <div style="margin-bottom:20px">
            <img src="~/images/登录.png" style="width:10%" /><input id="user" class="easyui-textbox" prompt="登录账号" iconWidth="28" style="width:100%;height:34px;padding:10px;">
        </div>
        <div style="margin-bottom:20px">
            <img src="~/images/密码.png" style="width:8%" /><input id="pass" class="easyui-passwordbox" prompt="登录密码" iconWidth="28" style="width:100%;height:34px;padding:10px">
        </div>
        <a href="#" class="easyui-linkbutton" onclick="login();">登录</a>
        <a href="#" class="easyui-linkbutton" onclick="reset();" style="float:right">重置</a>
    </div>

</body>
</html>
<script type="text/javascript">
    $(window).keydown(function () {
        if (event.keyCode == "13") {
            login();
        }
    });
		$('#pass').passwordbox({
			inputEvents: $.extend({}, $.fn.passwordbox.defaults.inputEvents, {
				keypress: function(e){
					var char = String.fromCharCode(e.which);
					$('#viewer').html(char).fadeIn(200, function(){
						$(this).fadeOut();
					});
				}
			})
        })
    function login() {
        var user = $('#user').textbox('getValue');
        var pass = $('#pass').textbox('getValue');
        if (user.length > 10 || pass.length > 10) {
            alert('请输入有效账号密码！');
        }

        $.ajax({
            type: 'post',
            url: '/Home/Login',
            data: { user: user, pass: pass },
            success: function (data) {
                if (JSON.stringify(data) == "[]") {
                    alert('信息输入有误！请重新输入！');
                } else {
                    var name = data[0].姓名;
                    sessionStorage.setItem('name', name); // 存入姓名给session
                    window.location=("/Home/Index");
                    window.close();
                }
            }
        });
    }
    function reset() {
        $('#user').textbox('setValue', null);
        $('#pass').textbox('setValue', null);
    }
</script>
